<!-- myParticipate -->
<template>
  <!-- 卡片 -->
  <el-card class="box-card el-card-flex">
    <div slot="header" class="clearfix">
      <span>
        <i class="el-icon-warning-outline"></i>
        我参与的
      </span>
    </div>
    <!-- 表格 -->
    <div class="text item">
      <el-form :inline="true" class="demo-form-inline" style="float: left;height:43px" @submit.native.prevent>
        <el-form-item>
          <el-input clearable placeholder="请输入任务编码或内容" v-model="textSearch" @keyup.enter.native="searchTabeleEnter"
            @clear="searchTabeleEnter" style="width:240px;">
            <el-button slot="append" icon="el-icon-search" @click="searchTabel"></el-button>
          </el-input>
        </el-form-item>
      </el-form>
      <div class="el-flex el-box-column">

        <el-table border height="100%" style="border-bottom: 40px solid transparent;" :data="tableData" stripe ref="firstTale">
          <el-table-column type="index" min-width="55px" label="序号" align="center" sortable show-overflow-tooltip></el-table-column>

          <el-table-column prop="taskCode" min-width="150px" label="任务编码" align="center" sortable show-overflow-tooltip></el-table-column>
          <el-table-column prop="taskContent" min-width="120px" label="任务内容" align="left" sortable
            show-overflow-tooltip></el-table-column>
          <el-table-column prop="taskStatus" min-width="100px" label="任务状态" align="center" sortable
            show-overflow-tooltip></el-table-column>
          <el-table-column prop="principal" min-width="100px" label="负责人" align="center" sortable show-overflow-tooltip></el-table-column>
          <el-table-column prop="issueDate" min-width="100px" label="发布日期" align="center" sortable
            show-overflow-tooltip></el-table-column>
          <el-table-column prop="expirationDate" min-width="150px" label="要求完成日期" align="center" sortable
            show-overflow-tooltip></el-table-column>
          <el-table-column prop="control" align="center" label="操作" fixed="right" width='90px'>
            <template slot-scope="scope">
              <el-button class="td-btn-icon" type="text" title="查看" @click='handleDetails(scope.$index, scope.row)'
                icon="el-icon-zoom-in"></el-button>
            </template>
          </el-table-column>

        </el-table>
        <el-pagination style="background: #fff; height: 32px; padding-top: 11px;left: 7px;" class="pagination"
          @size-change="handleSizeChange" @current-change="handleCurrentChange" background :current-page="currentPage"
           :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
      </div>
    </div>

  </el-card>
</template>
<script>
  import {
    Tree,
    Dialog,
    Table,
    TableColumn,
    Pagination,
    MessageBox,
    Message,
    Tag,
    Upload,
    Drawer
  } from 'element-ui';
  import {
    taskList, //列表数据
  } from '@/api/missionCenter/missionCenter.js'
  export default {
    name: 'myParticipate',
    components: {
      'el-tree': Tree, //树形菜单
      'el-dialog': Dialog, //对话框
      'el-table': Table, //表格
      'el-table-column': TableColumn, //表格列
      'el-pagination': Pagination, //分页
      'el-tag': Tag, //标签
      'el-drawer': Drawer
    },
    data() {
      let domainInlineSearchVal = {
        category: "3",
        endDate: "",
        expression: "",
        principal: "",
        qutryType: "1",
        startDate: "",
        taskCode: "",
        taskContent: "",
        taskStatus: ""
      }
      return {
        formInline: JSON.parse(JSON.stringify(domainInlineSearchVal)), // 系统管理高级查询条件
        textSearch: "",
        pageSize: 20,
        total: 0,
        currentPage: 1,
        tableData: [],
        isTreeTable: true
      };
    },
    created() {
      this.getTabTree(this.formInline)
      window.onresize = () => {
        this.$refs.tableData.doLayout()
      }
    },
    methods: {
      getTabTree(formInline) {
        taskList(this.currentPage, this.pageSize, formInline).then(res => {
          if (res.data.code == 10000) {
            res.data.data.records.forEach(e => {
              if (e.taskStatus == '1ca469fb397544d78546e8473a0e3cb8') {
                e.taskStatus = '起草'
              } else if (e.taskStatus == 'c2cd78d1eea54923970dfdcf5898ce92') {
                e.taskStatus = '已发布'
              } else if (e.taskStatus == '63adce50bfd344b58b2b3016e7318a17') {
                e.taskStatus = '办理中'
              } else if (e.taskStatus == '7b622176258245d6bb7ea0f3541845ba') {
                e.taskStatus = '已办结'
              } else if (e.taskStatus == '4fae11baea0b4b61b16b175251c2cd78') {
                e.taskStatus = '系统办结'
              } else if (e.taskStatus == 'a3bcf69d7e7c4572a3c0f7cefbb26432') {
                e.taskStatus = '已终止'
              } else if (e.taskStatus == 'a3bcf69d7e7c4572a3c0f7cefbb26432') {
                e.taskStatus = '系统终止'
              } else if (e.taskStatus == 'b834147cb5b34e1db80a7cb92dbe6869') {
                e.taskStatus = '已接收'
              } else if (e.taskStatus == '9f1a00d46cb042cb94b44fdda423dfc4') {
                e.taskStatus = '已拒绝'
              }
            })
            this.tableData = res.data.data.records
            this.total = res.data.data.total
          }
        }).catch(res => {
          resolve([])
        })
      },

      /*跳转到新增功能路由组件*/
      handleDetails(index, row) {
        //this.multiRouters是全局提供的自动添加多级路由的方法
        row.justLook = 'Y'
        sessionStorage.lookTaskId = row.taskId;
        sessionStorage.justLook = row.justLook;
        sessionStorage.lookshowTab = '我参与的';
        this.$router.addRoutes(this.multiRouters([{
          path: 'notifyLook',
          name: 'notifyLook', //自定义name名称
          component: () => import('@/views/thematicPortal/missionCenter/myNotify_look'),
          meta: {
            title: '办理'
          }
        }]));
        this.$router.push(this.routerMatch({
          name: "notifyLook", //顶部导航+侧边导航
          params: {
            row: row
          }
        }))
      },

      // 回车事件
      searchTabeleEnter() {
        this.searchTabel()
      },
      // 搜索事件
      searchTabel() {
        if (this.textSearch) { // 有数据,是要搜索
          this.formInline.expression = this.textSearch
          this.getTabTree(this.formInline)
        } else { // 搜索输入框是空的,说明是要重置,不搜索了,展示正常的全部数据
          this.searchData = ''
          this.formInline.expression = ''
          this.getTabTree(this.formInline)
        }
      },
      handleSizeChange(val) { //每页条数
        this.pageSize = val;
        this.getTabTree(this.formInline)
      },
      handleCurrentChange(val) { //当前页数
        this.currentPage = val;
        this.getTabTree(this.formInline)
      },
    }
  };
</script>

<style lang="scss">
  .el-card__body {
    position: relative;
  }

  .pagination.el-pagination {
    position: absolute;
    bottom: 5px;
    left: 15px;
  }

  .el-form-tag {
    margin-bottom: 8px !important;
  }

  .el-form-tag .el-tag {
    margin-bottom: 10px;
    margin-left: 0 !important;
    margin-right: 10px !important;
  }

  .el-input:not(.el-input--suffix) .el-input__inner[readonly] {
    background: none !important;
  }
</style>
